﻿<phone:PhoneApplicationPage 
    x:Class="ActivityTracker.Daily_TimespentPieChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:customControls="clr-namespace:CustomControls;assembly=PieChartCustomControl"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False" Loaded="PhoneApplicationPage_Loaded">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="customControls:PieChartLabel" x:Key="pieChartLabelStyle">
            <Setter Property="LineStrokeThickness" Value="0"/>
            <Setter Property="LineStroke" Value="Black"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="customControls:PieChartLabel">
                        <Canvas Name="Panel_PART">
                            <Polyline Name="Polyline_PART" StrokeThickness="{TemplateBinding LineStrokeThickness}" Stroke="{TemplateBinding LineStroke}" StrokeLineJoin="Round" />
                            <StackPanel Background="{StaticResource PhoneAccentBrush}" Name="Content_PART">
                                <Border BorderThickness="1" BorderBrush="Gray">
                                    <StackPanel Background="{StaticResource PhoneAccentBrush}"  Orientation="Horizontal">
                                        <TextBlock Text="{Binding ActName}" Foreground="{StaticResource PhoneForegroundBrush}"  Margin="0,0,5,0" FontSize="24"/>
                                    </StackPanel>
                                </Border>
                            </StackPanel>
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="Details">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Name: " Grid.Column="0" Grid.Row="0" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="{Binding ActName}" Grid.Column="1" Grid.Row="0" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="Duration: " Grid.Column="0" Grid.Row="1" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="{Binding ActDur}" Grid.Column="1" Grid.Row="1" Style="{StaticResource PhoneTextTitle3Style}"/>
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource bipivot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="8,17,0,10">
            <TextBlock x:Name="ApplicationTitle" Foreground="White" Text="ACTIVITY TRACKER - GROUPED BY ACTIVITY" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel x:Name="stpdate" Grid.Row="0" Orientation="Horizontal">
                <TextBlock x:Name="txtblktime" Foreground="White" Width="180" HorizontalAlignment="Center" VerticalAlignment="Center" Text="choose date" Style="{StaticResource PhoneTextTitle2Style}" ></TextBlock>
                <toolkit:DatePicker Foreground="White" x:Name="chartdtp" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="186"></toolkit:DatePicker>
            </StackPanel>
            <StackPanel Grid.Row="1">
                <ContentControl ContentTemplate="{StaticResource Details}" HorizontalAlignment="Left" x:Name="DetailsControl"/>
            </StackPanel>
            <StackPanel Grid.Row="2">
                <customControls:LabeledPieChart x:Name="mydailyChart" Height="540"  Width="480" Margin="-6,0,0,0">
                    <customControls:LabeledPieChart.Series>
                        <customControls:LabeledPieSeries x:Name="labeledPieSeries" ItemsSource="{Binding}" IndependentValuePath="ActName" DependentValuePath="ActDur" IsSelectionEnabled="True" PieChartLabelStyle="{StaticResource pieChartLabelStyle}" LabelDisplayMode="AutoMixed" SelectionChanged="labeledPieSeries_SelectionChanged"/>
                    </customControls:LabeledPieChart.Series>
                </customControls:LabeledPieChart>
            </StackPanel>
            <TextBlock Grid.Row="2" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="txtblkResult" Text="Data not available for this date" Visibility="Collapsed"/>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="btnbarchart" IconUri="/Images/barchart.png" Text="bar chart" Click="btnbarchart_Click" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Group By Category" Click="ApplicationBarMenuItem_Click">
                </shell:ApplicationBarMenuItem>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
